import { request } from 'umi';

export async function userRegistry(body: API.UserRegisterDTO, options?: { [key: string]: any }) {
  return request<BaseResponse<boolean>>('/api/user/registry', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

export async function userLogin(body: API.UserLoginDTO, options?: { [key: string]: any }) {
  return request<BaseResponse<API.UserVo>>('/api/user/login', {
    method: 'POST',
    data: body,
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
  });
}

export async function currentUser() {
  return request<BaseResponse<API.UserVo>>(`/api/user/current`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
  });
}
